package com.suxin.cgib;

import org.springframework.cglib.core.DebuggingClassWriter;
import org.springframework.cglib.proxy.Enhancer;

/**
 * @author Tang
 * @classname CgLibProxy
 * @description [  ]
 * @date 2021/7/19 16:49
 */
public class CgLibProxy {

    public static void main(String[] args) {
        System.setProperty(DebuggingClassWriter.DEBUG_LOCATION_PROPERTY, "G:\\suxin");
        Enhancer enhancer = new Enhancer();
        // 设置目标类的字节码文件
        enhancer.setSuperclass(Dog.class);
        // 设置回调
        enhancer.setCallback(new MyMethodInterceptor());
        Dog dog = (Dog)enhancer.create();
        dog.eat();
    }

}